package tt.dz.appserver.dao.ext;

import java.util.List;

import org.apache.commons.collections.map.ListOrderedMap;
import org.springframework.stereotype.Repository;

import tt.dz.appserver.dao.base.BasisDao;
import tt.dz.appserver.entity.model.pub.Infomation;
import tt.dz.appserver.util.Constants;
import tt.dz.appserver.util.enums.Valid;

@Repository
public class InfomationDao extends BasisDao<Infomation>{
	
	/**资讯增加*/
	public int addInfomation(Infomation Infomation) {
				
		return super.save(Infomation); 
	}
	
	/**资讯删除*/
	public int delInfomation(Infomation Infomation) {
		
		return super.update(Infomation);		
	}
	
	/**资讯更新*/
	public int updateInfomation(Infomation Infomation) {
		
		return super.update(Infomation);
	}
	
	/**资讯查找*/
	public List<Infomation> findInfomationValid() {
		
		Integer validflag = 1;
		ListOrderedMap map = new ListOrderedMap();
		map.put("valid_flag", validflag);
		
		return super.findListAutomaticOfClass(Infomation.class, map, null, null, "create_time", 2);
	}
	
	/**
	 * 获取资讯列表
	 * @param isRecommend
	 * @param pageNo
	 * @return
	 */
	public List<Infomation> findInfomationList(int pageNo){
		
		List<Infomation> InfomationsList = null;
		
		Infomation Infomation = new Infomation();
		Infomation.setValid_flag(Valid.YES.getValue());
		InfomationsList = super.findExample(Infomation, pageNo, Constants.PAGE_SIZE, "create_time", 0);
		return InfomationsList;
	}

}
